import type { SogouElements } from '../../../../../../../../types/constants/personalization/sogou'
import { ThemeVarService } from '../../../../../../../../lib/abstract/style/theme_var/service'
import {
  PAGE_ELEMENTS,
  SUPPORTED_PLATFORMS,
} from '../../../../../../../../types/constants'
import { SearchCommonStyles } from '../../common'

export class SogouVideoPage {
  elements: SogouElements = PAGE_ELEMENTS[SUPPORTED_PLATFORMS.SO_GOU]
  private static instance: SogouVideoPage
  private readonly themeVarService: ThemeVarService = ThemeVarService.getInstance()
  private readonly searchCommonStyles: SearchCommonStyles = SearchCommonStyles.getInstance()

  /**
   * 获取单例实例
   */
  public static getInstance(): SogouVideoPage {
    if (!SogouVideoPage.instance) {
      SogouVideoPage.instance = new SogouVideoPage()
    }
    return SogouVideoPage.instance
  }

  init(): void {
  }

  /**
   * 无搜索结果样式
   */
  noSearchResult(): string {
    return ``
  }

  getMainStyles(): string {
    return `
#wrap {
  /* 顶部菜单 */ 
  #header {
    background-color: var(${this.themeVarService.search.header.background}) !important;
    border-bottom: none !important;
    display: flex !important;
    justify-content: center !important;
    flex-direction: column !important;
    align-items: center !important;

    .search-main {
      margin-left: 0 !important;
      position: relative !important;
      
      .suggestion {
        left: 0 !important;
        top: 32px !important;
        width: calc(100% - 1px) !important;
        
        /* 搜索建议 */
        .suginner:not(:has(.s_title)) {
          .suglist {
            > li {            
              span {
                color: var(${this.themeVarService.em.text}) !important;
                
                b {
                  color: var(${this.themeVarService.search.suggestions.text}) !important;
                  font-weight: 400 !important;
                }
              }
            }
          }
        }
        
        /* 今日热搜 */
        .suginner:has(.s_title) {
          .s_title {
            color: var(${this.themeVarService.search.suggestions.text}) !important;
          }

          .suglist {
            > li {
              &:hover {
                span {
                  color: var(${this.themeVarService.link.default.text}) !important;
                }
              }
              
              span {
                color: var(${this.themeVarService.search.suggestions.text}) !important;
              }
            }
          }
        }
      }
    }
    .header-nav {
      margin-left: 0 !important;
    }
    .access-result {
      color: var(${this.themeVarService.search.default.text}) !important;
      
      &:hover {
        color: var(${this.themeVarService.link.default.text}) !important;
      }
    }
  }
  
  /* 主内容 */
  #container {
    background-color: transparent !important;
    
    .result-cartoon {
      background-color: transparent !important;
      margin: 0 auto !important;
      
      .srch-main {
        width: 100% !important; 

        .short-video-list {
          .sort_lst_bx {
            width: 100% !important; 

            /* 视频列表*/
            ul {
              ${this.searchCommonStyles.resultContainerStyles({ columns: 5 })}
              margin-bottom: ${this.themeVarService.search.resultItem.gap} !important;
              
              /* 视频列表项 */
              > .short-video-item {
                ${this.searchCommonStyles.resultItemStyles()}
                display: flex !important;
                flex-direction: column !important;
                justify-content: center !important;
                align-items: center !important;
                margin: 0 !important;
                
                .sort_lst_tit2 {
                  a {
                    color: var(${this.themeVarService.link.default.text}) !important;
                    
                    &:hover {
                      color: var(${this.themeVarService.link.default.textHover}) !important;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  
  /* 页脚 */
  .footer-result {
    position: fixed !important;
    bottom: 0 !important;
    width: 100% !important;
    background-color: transparent !important;
    border-top: none !important;
    
    p, p .g {
      color: var(${this.themeVarService.search.default.text}) !important;
    }
    
    a {
      color: var(${this.themeVarService.link.default.text}) !important;

      &:hover {
        color: var(${this.themeVarService.link.default.textHover}) !important;
      }
    }
  }
}
`
  }
}
